import math

factors = []
for i in range(10):
    factors.append(math.factorial(i))
print(factors)


def is_part_fact_sum(num):
    for j in str(num):
        num -= factors[int(j)]
    return num == 0


if __name__ == '__main__':
    res = 0
    for i in range(10, 10000000):
        if is_part_fact_sum(i):
            print(i)
            res += i
    print(res)
